package com.lwj.liwanjia.utils;


import com.lwj.liwanjia.config.URLConstant;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017/6/9.
 */

public class RetrofitHelper {
    private static Retrofit retrofit = null;

    public RetrofitHelper() {
        retrofit = getSingleRetrofit();
    }

    public static Retrofit getSingleRetrofit() {
        if (retrofit == null) {
            synchronized (RetrofitHelper.class) {
                if (retrofit == null) {
                    retrofit = new Retrofit.Builder()
                            .baseUrl(URLConstant.BASE_URL)
                            .client(OkHttp3Helper.getSingleInstance())
                            .addConverterFactory(GsonConverterFactory.create())
                            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                            .build();

                }
            }
        }
        return retrofit;
    }

}
